package test1;

import static org.junit.Assert.*;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestList {
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testArrayList() {
		
	//	Arrays.sort(as);
		String[][] ss=new String[3][];
		ss[0]=new String[2];
		//List<String> list=new ArrayList<String>();
		//List<String> list=new LinkedList<String>();
		List<String> list=new Vector<String>();
		list.add("abc");
		list.add("xya");
		list.add("123");
		list.add("123");
		
		//list.remove(1);
		//list.remove("xya");
		
		//System.out.println(list.get(2));
		for(String s:list){
			System.out.println(s);
			
		}
		
		
	}
	
	@Test
	public void testSet() {
	//	Set<String> set=new HashSet<String>(16,0.8f);
		Set<String> set=new TreeSet<String>();
		set.add("xay");
		set.add("123");
		set.add("dsfsd");
		set.add("ewwer");
		set.add("2sdsd");
		set.add("123");
		
		for(String s:set){
			System.out.println(s);
		}
	}
	
	@Test
	public void testSet1() {
		Set<User> set=new TreeSet<User>(new IdComparator());
		User u1=new User(1,"john",100);
		User u2=new User(2,"tom",23);
		User u3=new User(3,"kitty",45);
		User u4=new User(4,"kitty123",45);
		set.add(u1);set.add(u2);set.add(u3);
		set.add(u4);
		
		for(User u:set){
			System.out.println(u.getId()+"\t"+u.getName()+"\t"+u.getAge());
		}
		
	}
	
	@Test
	public void testMap() {
		Map<String, String> map=new HashMap<String,String>();
		map.put("a", "abc");
		map.put("d", "dabc");
		map.put("c", "Sabc");
		map.put("b", "abc");
		map.put("b", "abc1");
		System.out.println(map.get("a"));
		map.remove("c");
		for(String key:map.keySet()){
			System.out.println(key+"\t"+map.get(key));
		}
		
	}
	@Test
	public void testProperties() throws Exception{
		Properties pro=new Properties();
		pro.load(new FileInputStream("db.properties"));
		String s=pro.getProperty("user");
		System.out.println(s);
	}

}









